{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from AKData import AKData\n",
    "akdata = AKData(database_type=\"csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from futures_display_main_sina.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>symbol</th>\n",
       "      <th>exchange</th>\n",
       "      <th>name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>V0</td>\n",
       "      <td>dce</td>\n",
       "      <td>PVC连续</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>P0</td>\n",
       "      <td>dce</td>\n",
       "      <td>棕榈油连续</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>B0</td>\n",
       "      <td>dce</td>\n",
       "      <td>豆二连续</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>M0</td>\n",
       "      <td>dce</td>\n",
       "      <td>豆粕连续</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>I0</td>\n",
       "      <td>dce</td>\n",
       "      <td>铁矿石连续</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  symbol exchange   name\n",
       "0     V0      dce  PVC连续\n",
       "1     P0      dce  棕榈油连续\n",
       "2     B0      dce   豆二连续\n",
       "3     M0      dce   豆粕连续\n",
       "4     I0      dce  铁矿石连续"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 主连代码查询\n",
    "akdata.futures_display_main_sina().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from futures_main_sina.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>持仓量</th>\n",
       "      <th>动态结算价</th>\n",
       "      <th>symbol</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2021-05-06</td>\n",
       "      <td>7620</td>\n",
       "      <td>7934</td>\n",
       "      <td>7620</td>\n",
       "      <td>7890</td>\n",
       "      <td>517961</td>\n",
       "      <td>391326</td>\n",
       "      <td>7820</td>\n",
       "      <td>P0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2021-05-07</td>\n",
       "      <td>7890</td>\n",
       "      <td>8080</td>\n",
       "      <td>7834</td>\n",
       "      <td>8026</td>\n",
       "      <td>655909</td>\n",
       "      <td>404267</td>\n",
       "      <td>7980</td>\n",
       "      <td>P0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2021-05-10</td>\n",
       "      <td>8102</td>\n",
       "      <td>8120</td>\n",
       "      <td>7900</td>\n",
       "      <td>7954</td>\n",
       "      <td>853357</td>\n",
       "      <td>396794</td>\n",
       "      <td>8012</td>\n",
       "      <td>P0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2021-05-11</td>\n",
       "      <td>7966</td>\n",
       "      <td>8054</td>\n",
       "      <td>7836</td>\n",
       "      <td>7998</td>\n",
       "      <td>685019</td>\n",
       "      <td>402032</td>\n",
       "      <td>7966</td>\n",
       "      <td>P0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2021-05-12</td>\n",
       "      <td>8022</td>\n",
       "      <td>8344</td>\n",
       "      <td>7956</td>\n",
       "      <td>8338</td>\n",
       "      <td>812215</td>\n",
       "      <td>413415</td>\n",
       "      <td>8172</td>\n",
       "      <td>P0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        date  open  high   low  close  volume     持仓量  动态结算价 symbol\n",
       "0 2021-05-06  7620  7934  7620   7890  517961  391326   7820     P0\n",
       "1 2021-05-07  7890  8080  7834   8026  655909  404267   7980     P0\n",
       "2 2021-05-10  8102  8120  7900   7954  853357  396794   8012     P0\n",
       "3 2021-05-11  7966  8054  7836   7998  685019  402032   7966     P0\n",
       "4 2021-05-12  8022  8344  7956   8338  812215  413415   8172     P0"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查询单只主连合约\n",
    "df = akdata.futures_main_sina(\n",
    "    symbol=\"P0\",\n",
    "    start_date=np.datetime64(\"2021-05-01\"),\n",
    "    end_date=np.datetime64(\"2024-09-24\"),\n",
    ")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>item</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>代码</td>\n",
       "      <td>SH000001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>52周最高</td>\n",
       "      <td>3174.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>均价</td>\n",
       "      <td>2957.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>涨幅</td>\n",
       "      <td>2.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>流通股</td>\n",
       "      <td>4451970546116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>振幅</td>\n",
       "      <td>2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>现价</td>\n",
       "      <td>2957.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>最高</td>\n",
       "      <td>2961.4205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>今年以来涨幅</td>\n",
       "      <td>-0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>流通值</td>\n",
       "      <td>25239885076364.878906</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>发行日期</td>\n",
       "      <td>661536000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>最低</td>\n",
       "      <td>2889.0143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>资产净值/总市值</td>\n",
       "      <td>46018634337915.15625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>货币</td>\n",
       "      <td>CNY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>最小交易单位</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>成交额</td>\n",
       "      <td>343913325097.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>涨跌</td>\n",
       "      <td>60.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>昨收</td>\n",
       "      <td>2896.3057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>成交量</td>\n",
       "      <td>39566203200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>周转率</td>\n",
       "      <td>0.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>52周最低</td>\n",
       "      <td>2635.0897</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>名称</td>\n",
       "      <td>上证指数</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>交易所</td>\n",
       "      <td>SH</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>时间</td>\n",
       "      <td>2024-09-26 13:45:11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>基金份额/总股本</td>\n",
       "      <td>15561661562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>今开</td>\n",
       "      <td>2893.7451</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        item                  value\n",
       "0         代码               SH000001\n",
       "1      52周最高                3174.27\n",
       "2         均价                2957.18\n",
       "3         涨幅                    2.1\n",
       "4        流通股          4451970546116\n",
       "5         振幅                    2.5\n",
       "6         现价                2957.18\n",
       "7         最高              2961.4205\n",
       "8     今年以来涨幅                   -0.6\n",
       "9        流通值  25239885076364.878906\n",
       "10      发行日期           661536000000\n",
       "11        最低              2889.0143\n",
       "12  资产净值/总市值   46018634337915.15625\n",
       "13        货币                    CNY\n",
       "14    最小交易单位                    100\n",
       "15       成交额         343913325097.0\n",
       "16        涨跌                  60.87\n",
       "17        昨收              2896.3057\n",
       "18       成交量            39566203200\n",
       "19       周转率                   0.89\n",
       "20     52周最低              2635.0897\n",
       "21        名称                   上证指数\n",
       "22       交易所                     SH\n",
       "23        时间    2024-09-26 13:45:11\n",
       "24  基金份额/总股本            15561661562\n",
       "25        今开              2893.7451"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指数实时行情\n",
    "akdata.stock_individual_spot_xq(symbol=\"SH000001\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from index_hist_cni.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>volume</th>\n",
       "      <th>amount</th>\n",
       "      <th>symbol</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2015-01-05</td>\n",
       "      <td>5470.54</td>\n",
       "      <td>5502.20</td>\n",
       "      <td>5414.89</td>\n",
       "      <td>5501.43</td>\n",
       "      <td>0.0060</td>\n",
       "      <td>10993.01</td>\n",
       "      <td>1073.61</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-01-06</td>\n",
       "      <td>5479.37</td>\n",
       "      <td>5588.73</td>\n",
       "      <td>5446.35</td>\n",
       "      <td>5588.47</td>\n",
       "      <td>0.0158</td>\n",
       "      <td>10969.32</td>\n",
       "      <td>1135.61</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-01-07</td>\n",
       "      <td>5577.64</td>\n",
       "      <td>5588.78</td>\n",
       "      <td>5544.05</td>\n",
       "      <td>5587.70</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>9268.54</td>\n",
       "      <td>969.23</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015-01-08</td>\n",
       "      <td>5582.12</td>\n",
       "      <td>5611.13</td>\n",
       "      <td>5544.64</td>\n",
       "      <td>5576.30</td>\n",
       "      <td>-0.0020</td>\n",
       "      <td>9301.60</td>\n",
       "      <td>981.49</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015-01-09</td>\n",
       "      <td>5562.44</td>\n",
       "      <td>5612.30</td>\n",
       "      <td>5540.17</td>\n",
       "      <td>5540.17</td>\n",
       "      <td>-0.0065</td>\n",
       "      <td>8569.63</td>\n",
       "      <td>939.72</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        date     open     high      low    close     涨跌幅    volume   amount  \\\n",
       "0 2015-01-05  5470.54  5502.20  5414.89  5501.43  0.0060  10993.01  1073.61   \n",
       "1 2015-01-06  5479.37  5588.73  5446.35  5588.47  0.0158  10969.32  1135.61   \n",
       "2 2015-01-07  5577.64  5588.78  5544.05  5587.70 -0.0001   9268.54   969.23   \n",
       "3 2015-01-08  5582.12  5611.13  5544.64  5576.30 -0.0020   9301.60   981.49   \n",
       "4 2015-01-09  5562.44  5612.30  5540.17  5540.17 -0.0065   8569.63   939.72   \n",
       "\n",
       "   symbol  \n",
       "0  399303  \n",
       "1  399303  \n",
       "2  399303  \n",
       "3  399303  \n",
       "4  399303  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 国证指数查询\n",
    "df = akdata.index_hist_cni(\n",
    "    symbol=\"399303\",\n",
    "    start_date=np.datetime64(\"2015-01-01\"),\n",
    "    end_date=np.datetime64(\"2024-09-24\"),\n",
    "    rewrite=False,\n",
    ")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from stock_zh_index_hist_csindex.csv\n",
      "rewrite stock_zh_index_hist_csindex data\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>指数代码</th>\n",
       "      <th>指数中文全称</th>\n",
       "      <th>指数中文简称</th>\n",
       "      <th>指数英文全称</th>\n",
       "      <th>指数英文简称</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>涨跌</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>volume</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>样本数量</th>\n",
       "      <th>滚动市盈率</th>\n",
       "      <th>symbol</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>000852</td>\n",
       "      <td>中证1000指数</td>\n",
       "      <td>中证1000</td>\n",
       "      <td>CSI 1000 Index</td>\n",
       "      <td>CSI 1000</td>\n",
       "      <td>6025.75</td>\n",
       "      <td>6052.44</td>\n",
       "      <td>5948.27</td>\n",
       "      <td>6049.79</td>\n",
       "      <td>22.27</td>\n",
       "      <td>0.37</td>\n",
       "      <td>9480.52</td>\n",
       "      <td>1012.88</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>46.34</td>\n",
       "      <td>000852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-01-05</td>\n",
       "      <td>000852</td>\n",
       "      <td>中证1000指数</td>\n",
       "      <td>中证1000</td>\n",
       "      <td>CSI 1000 Index</td>\n",
       "      <td>CSI 1000</td>\n",
       "      <td>6025.75</td>\n",
       "      <td>6052.44</td>\n",
       "      <td>5948.27</td>\n",
       "      <td>6049.79</td>\n",
       "      <td>22.27</td>\n",
       "      <td>0.37</td>\n",
       "      <td>9480.52</td>\n",
       "      <td>1012.88</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>46.34</td>\n",
       "      <td>000852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-01-06</td>\n",
       "      <td>000852</td>\n",
       "      <td>中证1000指数</td>\n",
       "      <td>中证1000</td>\n",
       "      <td>CSI 1000 Index</td>\n",
       "      <td>CSI 1000</td>\n",
       "      <td>6021.45</td>\n",
       "      <td>6172.64</td>\n",
       "      <td>5986.40</td>\n",
       "      <td>6172.39</td>\n",
       "      <td>122.61</td>\n",
       "      <td>2.03</td>\n",
       "      <td>9399.20</td>\n",
       "      <td>1100.59</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>47.39</td>\n",
       "      <td>000852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015-01-07</td>\n",
       "      <td>000852</td>\n",
       "      <td>中证1000指数</td>\n",
       "      <td>中证1000</td>\n",
       "      <td>CSI 1000 Index</td>\n",
       "      <td>CSI 1000</td>\n",
       "      <td>6161.48</td>\n",
       "      <td>6171.15</td>\n",
       "      <td>6118.14</td>\n",
       "      <td>6166.77</td>\n",
       "      <td>-5.62</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>8062.01</td>\n",
       "      <td>932.45</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>47.31</td>\n",
       "      <td>000852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015-01-08</td>\n",
       "      <td>000852</td>\n",
       "      <td>中证1000指数</td>\n",
       "      <td>中证1000</td>\n",
       "      <td>CSI 1000 Index</td>\n",
       "      <td>CSI 1000</td>\n",
       "      <td>6161.55</td>\n",
       "      <td>6211.46</td>\n",
       "      <td>6126.97</td>\n",
       "      <td>6164.11</td>\n",
       "      <td>-2.66</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>8131.56</td>\n",
       "      <td>958.07</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>47.33</td>\n",
       "      <td>000852</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         date    指数代码    指数中文全称  指数中文简称          指数英文全称    指数英文简称     open  \\\n",
       "0  2015-01-01  000852  中证1000指数  中证1000  CSI 1000 Index  CSI 1000  6025.75   \n",
       "1  2015-01-05  000852  中证1000指数  中证1000  CSI 1000 Index  CSI 1000  6025.75   \n",
       "2  2015-01-06  000852  中证1000指数  中证1000  CSI 1000 Index  CSI 1000  6021.45   \n",
       "3  2015-01-07  000852  中证1000指数  中证1000  CSI 1000 Index  CSI 1000  6161.48   \n",
       "4  2015-01-08  000852  中证1000指数  中证1000  CSI 1000 Index  CSI 1000  6161.55   \n",
       "\n",
       "      high      low    close      涨跌   涨跌幅   volume     成交金额    样本数量  滚动市盈率  \\\n",
       "0  6052.44  5948.27  6049.79   22.27  0.37  9480.52  1012.88  1000.0  46.34   \n",
       "1  6052.44  5948.27  6049.79   22.27  0.37  9480.52  1012.88  1000.0  46.34   \n",
       "2  6172.64  5986.40  6172.39  122.61  2.03  9399.20  1100.59  1000.0  47.39   \n",
       "3  6171.15  6118.14  6166.77   -5.62 -0.09  8062.01   932.45  1000.0  47.31   \n",
       "4  6211.46  6126.97  6164.11   -2.66 -0.04  8131.56   958.07  1000.0  47.33   \n",
       "\n",
       "   symbol  \n",
       "0  000852  \n",
       "1  000852  \n",
       "2  000852  \n",
       "3  000852  \n",
       "4  000852  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 中证指数查询\n",
    "df = akdata.stock_zh_index_hist_csindex(\n",
    "    symbol=\"000852\",\n",
    "    start_date=np.datetime64(\"2015-01-01\"),\n",
    "    end_date=np.datetime64(\"2024-09-24\"),\n",
    "    rewrite=False,\n",
    ")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from index_stock_info.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>symbol</th>\n",
       "      <th>display_name</th>\n",
       "      <th>publish_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001</td>\n",
       "      <td>上证指数</td>\n",
       "      <td>1991-07-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000002</td>\n",
       "      <td>A股指数</td>\n",
       "      <td>1992-02-21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000003</td>\n",
       "      <td>B股指数</td>\n",
       "      <td>1992-02-21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000004</td>\n",
       "      <td>工业指数</td>\n",
       "      <td>1993-05-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000005</td>\n",
       "      <td>商业指数</td>\n",
       "      <td>1993-05-03</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   symbol display_name publish_date\n",
       "0  000001         上证指数   1991-07-15\n",
       "1  000002         A股指数   1992-02-21\n",
       "2  000003         B股指数   1992-02-21\n",
       "3  000004         工业指数   1993-05-03\n",
       "4  000005         商业指数   1993-05-03"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指数列表查询\n",
    "df = akdata.index_stock_info()\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from index_stock_cons.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cons_symbol</th>\n",
       "      <th>品种名称</th>\n",
       "      <th>纳入日期</th>\n",
       "      <th>symbol</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>688551</td>\n",
       "      <td>科威尔</td>\n",
       "      <td>2024-09-18</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>605188</td>\n",
       "      <td>国光连锁</td>\n",
       "      <td>2024-08-28</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>002392</td>\n",
       "      <td>北京利尔</td>\n",
       "      <td>2024-08-19</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>688155</td>\n",
       "      <td>先惠技术</td>\n",
       "      <td>2024-08-12</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>002996</td>\n",
       "      <td>顺博合金</td>\n",
       "      <td>2024-06-17</td>\n",
       "      <td>399303</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  cons_symbol  品种名称        纳入日期  symbol\n",
       "0      688551   科威尔  2024-09-18  399303\n",
       "1      605188  国光连锁  2024-08-28  399303\n",
       "2      002392  北京利尔  2024-08-19  399303\n",
       "3      688155  先惠技术  2024-08-12  399303\n",
       "4      002996  顺博合金  2024-06-17  399303"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指数成分股查询\n",
    "## 国证2000\n",
    "df = akdata.index_stock_cons(symbol=\"399303\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data from index_stock_cons_csindex.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table  border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>symbol</th>\n",
       "      <th>指数名称</th>\n",
       "      <th>指数英文名称</th>\n",
       "      <th>cons_symbol</th>\n",
       "      <th>成分券名称</th>\n",
       "      <th>成分券英文名称</th>\n",
       "      <th>交易所</th>\n",
       "      <th>交易所英文名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024-09-25</td>\n",
       "      <td>932000</td>\n",
       "      <td>中证2000</td>\n",
       "      <td>CSI 2000</td>\n",
       "      <td>000010</td>\n",
       "      <td>美丽生态</td>\n",
       "      <td>SHENZHEN ECOBEAUTY CO., LTD.</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>Shenzhen Stock Exchange</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024-09-25</td>\n",
       "      <td>932000</td>\n",
       "      <td>中证2000</td>\n",
       "      <td>CSI 2000</td>\n",
       "      <td>000011</td>\n",
       "      <td>深物业A</td>\n",
       "      <td>Shenzhen Properties &amp; Resources Development (G...</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>Shenzhen Stock Exchange</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024-09-25</td>\n",
       "      <td>932000</td>\n",
       "      <td>中证2000</td>\n",
       "      <td>CSI 2000</td>\n",
       "      <td>000014</td>\n",
       "      <td>沙河股份</td>\n",
       "      <td>Shahe Industrial Co Ltd</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>Shenzhen Stock Exchange</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024-09-25</td>\n",
       "      <td>932000</td>\n",
       "      <td>中证2000</td>\n",
       "      <td>CSI 2000</td>\n",
       "      <td>000026</td>\n",
       "      <td>飞亚达</td>\n",
       "      <td>FIYTA Precision Technology Co., Ltd.</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>Shenzhen Stock Exchange</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024-09-25</td>\n",
       "      <td>932000</td>\n",
       "      <td>中证2000</td>\n",
       "      <td>CSI 2000</td>\n",
       "      <td>000036</td>\n",
       "      <td>华联控股</td>\n",
       "      <td>China Union Holdings Co Ltd</td>\n",
       "      <td>深圳证券交易所</td>\n",
       "      <td>Shenzhen Stock Exchange</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        date  symbol    指数名称    指数英文名称 cons_symbol 成分券名称  \\\n",
       "0 2024-09-25  932000  中证2000  CSI 2000      000010  美丽生态   \n",
       "1 2024-09-25  932000  中证2000  CSI 2000      000011  深物业A   \n",
       "2 2024-09-25  932000  中证2000  CSI 2000      000014  沙河股份   \n",
       "3 2024-09-25  932000  中证2000  CSI 2000      000026   飞亚达   \n",
       "4 2024-09-25  932000  中证2000  CSI 2000      000036  华联控股   \n",
       "\n",
       "                                             成分券英文名称      交易所  \\\n",
       "0                       SHENZHEN ECOBEAUTY CO., LTD.  深圳证券交易所   \n",
       "1  Shenzhen Properties & Resources Development (G...  深圳证券交易所   \n",
       "2                            Shahe Industrial Co Ltd  深圳证券交易所   \n",
       "3               FIYTA Precision Technology Co., Ltd.  深圳证券交易所   \n",
       "4                        China Union Holdings Co Ltd  深圳证券交易所   \n",
       "\n",
       "                   交易所英文名称  \n",
       "0  Shenzhen Stock Exchange  \n",
       "1  Shenzhen Stock Exchange  \n",
       "2  Shenzhen Stock Exchange  \n",
       "3  Shenzhen Stock Exchange  \n",
       "4  Shenzhen Stock Exchange  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指数成分股查询\n",
    "## 中证2000\n",
    "df = akdata.index_stock_cons_csindex(symbol=\"932000\")\n",
    "df.head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
